SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


CREATE PROCEDURE dbo.[DnnProduct_UpdatePortalSetting]
	@PortalID       int,
	@SettingName    nvarchar(50),
	@SettingValue   nvarchar(2000),
	@UserID			int,
	@CultureCode    nvarchar(50)

AS
	IF (SELECT COUNT(*) FROM dbo.DnnProduct_PortalSettings WHERE PortalID = @PortalID AND SettingName = @SettingName) > 0
		--Update
		UPDATE  dbo.DnnProduct_PortalSettings
			SET SettingValue = @SettingValue,
				[LastModifiedByUserID]=@UserID,
				[LastModifiedOnDate]=getdate()
		WHERE PortalID = @PortalID
			AND SettingName = @SettingName
			
	ELSE
		--Add
		INSERT INTO dbo.DnnProduct_PortalSettings ( PortalID, SettingName, SettingValue, CreatedByUserID, CreatedOnDate, LastModifiedByUserID, LastModifiedOnDate,CultureCode ) 
			VALUES ( @PortalID, @SettingName, @SettingValue ,@UserID ,getdate() ,@UserID ,getdate(),@CultureCode)
GO
